package com.ziwei.material.interceptor;

import brave.mysql8.TracingExceptionInterceptor;
import com.mysql.cj.exceptions.ExceptionInterceptor;
import com.mysql.cj.log.Log;

import java.util.Properties;

public class ZipkinTracingExceptionInterceptor extends TracingExceptionInterceptor {
    @Override
    public ExceptionInterceptor init(Properties properties, Log log) {
        String queryInterceptors = properties.getProperty("queryInterceptors");
        if (queryInterceptors != null && queryInterceptors.contains(ZipkinMysqlStatementInterceptor.class.getName())) {
            return new ZipkinTracingExceptionInterceptor();
        } else {
            throw new IllegalStateException("TracingQueryInterceptor must be enabled to use TracingExceptionInterceptor.");
        }
    }



}
